/*
 * NextWorldStepButtonListener.cpp
 *
 *  Created on: 15-01-2011
 *      Author: Przemek
 */

#include "listener/NextWorldStepButtonListener.hpp"
#include "world/World.hpp"

const float NextWorldStepButtonListener::SINGLE_FRAME_DT_IN_SECONDS = 0.3f;
const float NextWorldStepButtonListener::STEP_TIME_IN_SECONDS = 1.0f;

void NextWorldStepButtonListener::mouseReleased(const MouseListener::EventArguments&)
{
	World& world = World::getInstance();
	bool wasRunning = world.isRunning();
	world.setRunning(true);

	float timeInSeconds = SINGLE_FRAME_DT_IN_SECONDS;
	while(timeInSeconds < STEP_TIME_IN_SECONDS)
	{
		world.updateWithDeltaTime(1, SINGLE_FRAME_DT_IN_SECONDS);
		timeInSeconds += SINGLE_FRAME_DT_IN_SECONDS;
	}

	world.setRunning(wasRunning);
}
